class ListNode:
    def __init__(self, initdata, next=None):
        self.data = initdata
        self.next = next

    def getData(self):
        return self.data

    def getNext(self):
        return self.next

    def setData(self, newdata):
        self.data = newdata

    def setNext(self, newnext):
        self.next = newnext


class Solution:
    def __init__(self):
        self.head = None

    def add(self, item):
        current = self.head
        previous = None
        stop = False
        while current != None and not stop:
            if current.getData() > item:
                stop = True
            else:
                previous = current
                current = current.getNext()
        temp = ListNode(item)
        if previous == None:
            temp.setNext(self.head)
            self.head = temp
        else:
            temp.setNext(current)
            previous.setNext(temp)
    def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode:
        if l1 and l2:
            if l1.data > l2.data: l1, l2 = l2, l1
            l1.next = self.mergeTwoLists(l1.next, l2)
        return l1 or l2

lt1=list(map(int,input().split()))
lt2=list(map(int,input().split()))
s1 = Solution()
s2 = Solution()
for i in lt1:
    if i==-1:
        break
    s1.add(i)
for i in lt2:
    if i==-1:
        break
    s2.add(i)

res=s1.mergeTwoLists(s1.head,s2.head)
lt = []
while res is not None:
   lt.insert(0,res.getData())
   res = res.getNext()
for i in range(len(lt)-1,-1,-1):
    if i==0:
        print(lt[i],end='')
    else:
        print(lt[i],end=' ')
